<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">

    

    <title>
      iOS加密算法 | XTCEL 
    </title>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    
      <meta name="author" content="Jack Yong">
    
    

    <meta name="description" content="在iOS的项目中，我们经常会用到加密技术，比如说在登录的时候，我们会先把密码用MD5加密再传输给服务器或者直接对所有的参数进行加密再Post到服务器。">
<meta name="keywords" content="iOS,加密">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS加密算法 | XTCEL">
<meta property="og:url" content="http://xtcel.com/2014/10/28/iOS加密算法/index.html">
<meta property="og:site_name" content="XTCEL">
<meta property="og:description" content="在iOS的项目中，我们经常会用到加密技术，比如说在登录的时候，我们会先把密码用MD5加密再传输给服务器或者直接对所有的参数进行加密再Post到服务器。">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-01-11T08:53:23.423Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS加密算法 | XTCEL">
<meta name="twitter:description" content="在iOS的项目中，我们经常会用到加密技术，比如说在登录的时候，我们会先把密码用MD5加密再传输给服务器或者直接对所有的参数进行加密再Post到服务器。">
    
    
    
      <link rel="icon" type="image/x-icon" href="/images/avatar.png">
    
    <link rel="stylesheet" href="/css/uno.css">
    <link rel="stylesheet" href="/css/highlight.css">
    <link rel="stylesheet" href="/css/archive.css">
    <link rel="stylesheet" href="/css/china-social-icon.css">

</head>
<body>

    <span class="mobile btn-mobile-menu">
        <i class="icon icon-list btn-mobile-menu__icon"></i>
        <i class="icon icon-x-circle btn-mobile-close__icon hidden"></i>
    </span>

    

<header class="panel-cover panel-cover--collapsed">


  <div class="panel-main">

  
    <div class="panel-main__inner panel-inverted">
    <div class="panel-main__content">

        
        <a href="/" title="link to homepage for XTCEL"><img src="/images/avatar.png" width="80" alt="XTCEL logo" class="panel-cover__logo logo" /></a>
        

        <h1 class="panel-cover__title panel-title"><a href="/" title="link to homepage">XTCEL</a></h1>
        <hr class="panel-cover__divider" />

        
        <p class="panel-cover__description">
          关注技术   热爱设计
        </p>
        <hr class="panel-cover__divider panel-cover__divider--secondary" />
        

        <div class="navigation-wrapper">

          <nav class="cover-navigation cover-navigation--primary">
            <ul class="navigation">

              
                
                <li class="navigation__item"><a href="/#blog" title="" class="blog-button">首页</a></li>
              
                
                <li class="navigation__item"><a href="/about" title="" class="">关于</a></li>
              
                
                <li class="navigation__item"><a href="/archive" title="" class="">归档</a></li>
              

            </ul>
          </nav>

          <!-- ----------------------------
To add a new social icon simply duplicate one of the list items from below
and change the class in the <i> tag to match the desired social network
and then add your link to the <a>. Here is a full list of social network
classes that you can use:

    icon-social-500px
    icon-social-behance
    icon-social-delicious
    icon-social-designer-news
    icon-social-deviant-art
    icon-social-digg
    icon-social-dribbble
    icon-social-facebook
    icon-social-flickr
    icon-social-forrst
    icon-social-foursquare
    icon-social-github
    icon-social-google-plus
    icon-social-hi5
    icon-social-instagram
    icon-social-lastfm
    icon-social-linkedin
    icon-social-medium
    icon-social-myspace
    icon-social-path
    icon-social-pinterest
    icon-social-rdio
    icon-social-reddit
    icon-social-skype
    icon-social-spotify
    icon-social-stack-overflow
    icon-social-steam
    icon-social-stumbleupon
    icon-social-treehouse
    icon-social-tumblr
    icon-social-twitter
    icon-social-vimeo
    icon-social-xbox
    icon-social-yelp
    icon-social-youtube
    icon-social-zerply
    icon-mail

-------------------------------->

<!-- add social info here -->



<nav class="cover-navigation navigation--social">
  <ul class="navigation">

    
      <!-- Github -->
      <li class="navigation__item">
        <a href="https://github.com/xtcel" title="Huno on GitHub">
          <i class='icon icon-social-github'></i>
          <span class="label">GitHub</span>
        </a>
      </li>
    

    <!-- China social icon -->
    <!--
    
      <li class="navigation__item">
        <a href="" title="">
          <i class='icon cs-icon-douban'></i>
          <span class="label">Douban</span>
        </a>
      </li>

      <li class="navigation__item">
        <a href="" title="">
          <i class='icon cs-icon-weibo'></i>
          <span class="label">Weibo</span>
        </a>
      </li>

    -->



  </ul>
</nav>



        </div>

      </div>

    </div>

    <div class="panel-cover--overlay"></div>
  </div>
</header>

    <div class="content-wrapper">
        <div class="content-wrapper__inner entry">
            

<article class="post-container post-container--single">

  <header class="post-header">
    
    <h1 class="post-title">iOS加密算法</h1>

    

    <div class="post-meta">
      <time datetime="2014-10-28" class="post-meta__date date">2014-10-28</time> 

      <span class="post-meta__tags tags">

          

          
             &#8226; 标签:
            <font class="tags">
              <a class="tags-link" href="/tags/iOS/">iOS</a>, <a class="tags-link" href="/tags/加密/">加密</a>
            </font>
          

      </span>
    </div>
    
    

  </header>

  <section id="post-content" class="article-content post">
    <p>在iOS的项目中，我们经常会用到加密技术，比如说在登录的时候，我们会先把密码用MD5加密再传输给服务器或者直接对所有的参数进行加密再Post到服务器。<br><a id="more"></a></p>
<h3 id="常用加密算法："><a href="#常用加密算法：" class="headerlink" title="常用加密算法："></a>常用加密算法：</h3><ol>
<li>DES:Data Encryption Standard，即数据加密算法，它是IBM公司于1975年研究成功并公开发表的。</li>
<li>AES:高级加密标准，这个标准用来替代原先的DES，已经被多方分析且广为全世界所使用。高级加密标准已然成为对称密钥加密中最流行的算法之一。</li>
<li>MD5:Message-Digest Algorithm 5（信息-摘要算法5），用于确保信息传输完整一致。是计算机广泛使用的杂凑算法之一（又译摘要算法、哈希算法），主流编程语言普遍已有MD5实现。这个应该是听到最多的算法，据说是已经被破解了。但是我觉得破解这个应该也要很久吧！</li>
<li>Base64:Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一。Base64编码可用于在HTTP环境下传递较长的标识信息。例如，在Java Persistence系统Hibernate中，就采用了Base64来将一个较长的唯一 标识符（一般为128-bit的UUID）编码为一个字符串，用作HTTP表单和HTTP GET URL中的参数。在其应用程序中，也常常需要把二进制数据编码为适合放在URL（包括隐藏表单域）中的形式。此时，采用Base64编码具有不可读性，即所编码的数据不会被人用肉眼所直接看到。</li>
</ol>
<h3 id="算法实现"><a href="#算法实现" class="headerlink" title="算法实现"></a>算法实现</h3><p>介绍完这些算法，接下来我们就来看看它们再iOS下面的具体实现吧！<br>我再GitHub上做了一个小Demo，可以直接下载，放到项目中直接使用<br>链接地址:<a href="https://github.com/yongca887/XTSecurity/" target="_blank" rel="noopener">https://github.com/yongca887/XTSecurity/</a></p>
<p>一、DES加密算法<br>废话不多说了，直接上代码：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">+ (NSString *)encrypt:(NSString *)sText encryptOrDecrypt:(CCOperation)encryptOperation key:(NSString *)key</span><br><span class="line">&#123;</span><br><span class="line">const void *dataIn;</span><br><span class="line">size_t dataInLength;</span><br><span class="line">if (encryptOperation == kCCDecrypt)//传递过来的是decrypt 解码</span><br><span class="line">&#123;</span><br><span class="line">//解码 base64</span><br><span class="line">NSData *decryptData = [GTMBase64 decodeData:[sText dataUsingEncoding:NSUTF8StringEncoding]];//转成utf-8并decode</span><br><span class="line">dataInLength = [decryptData length];</span><br><span class="line">dataIn = [decryptData bytes];</span><br><span class="line">&#125;</span><br><span class="line">else //encrypt</span><br><span class="line">&#123;</span><br><span class="line">NSData* encryptData = [sText dataUsingEncoding:NSUTF8StringEncoding];</span><br><span class="line">dataInLength = [encryptData length];</span><br><span class="line">dataIn = (const void *)[encryptData bytes];</span><br><span class="line">&#125;</span><br><span class="line">/*</span><br><span class="line">DES加密 ：用CCCrypt函数加密一下，然后用base64编码下，传过去</span><br><span class="line">DES解密 ：把收到的数据根据base64，decode一下，然后再用CCCrypt函数解密，得到原本的数据</span><br><span class="line">*/</span><br><span class="line">CCCryptorStatus ccStatus;</span><br><span class="line">uint8_t *dataOut = NULL; //可以理解位type/typedef 的缩写（有效的维护了代码，比如：一个人用int，一个人用long。最好用typedef来定义）</span><br><span class="line">size_t dataOutAvailable = 0; //size_t 是操作符sizeof返回的结果类型</span><br><span class="line">size_t dataOutMoved = 0;</span><br><span class="line">dataOutAvailable = (dataInLength + kCCBlockSizeDES) &amp; ~(kCCBlockSizeDES – 1);</span><br><span class="line">dataOut = malloc( dataOutAvailable * sizeof(uint8_t));</span><br><span class="line">memset((void *)dataOut, 0x0, dataOutAvailable);//将已开辟内存空间buffer的首 1 个字节的值设为值 0</span><br><span class="line">NSString *initIv = @”12345678″;</span><br><span class="line">const void *vkey = (const void *) [key UTF8String];</span><br><span class="line">const void *iv = (const void *) [initIv UTF8String];</span><br><span class="line">//CCCrypt函数 加密/解密</span><br><span class="line">ccStatus = CCCrypt(encryptOperation,// 加密/解密</span><br><span class="line">kCCAlgorithmDES,// 加密根据哪个标准（des，3des，aes。。。。）</span><br><span class="line">kCCOptionPKCS7Padding,// 选项分组密码算法(des:对每块分组加一次密 3DES：对每块分组加三个不同的密)</span><br><span class="line">vkey, //密钥 加密和解密的密钥必须一致</span><br><span class="line">kCCKeySizeDES,// DES 密钥的大小（kCCKeySizeDES=8）</span><br><span class="line">iv, // 可选的初始矢量</span><br><span class="line">dataIn, // 数据的存储单元</span><br><span class="line">dataInLength,// 数据的大小</span><br><span class="line">(void *)dataOut,// 用于返回数据</span><br><span class="line">dataOutAvailable,</span><br><span class="line">&amp;dataOutMoved);</span><br><span class="line">NSString *result = nil;</span><br><span class="line">if (encryptOperation == kCCDecrypt)//encryptOperation==1 解码</span><br><span class="line">&#123;</span><br><span class="line">//得到解密出来的data数据，改变为utf-8的字符串</span><br><span class="line">result = [[NSString alloc] initWithData:[NSData dataWithBytes:(const void *)dataOut length:(NSUInteger)dataOutMoved] encoding:NSUTF8StringEncoding];</span><br><span class="line">&#125;</span><br><span class="line">else //encryptOperation==0 （加密过程中，把加好密的数据转成base64的）</span><br><span class="line">&#123;</span><br><span class="line">//编码 base64</span><br><span class="line">NSData *data = [NSData dataWithBytes:(const void *)dataOut length:(NSUInteger)dataOutMoved];</span><br><span class="line">result = [GTMBase64 stringByEncodingData:data];</span><br><span class="line">&#125;</span><br><span class="line">return result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>二、AES加密算法<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line">+(NSData *)AES256EncryptWithKey:(NSString *)key &#123;//加密</span><br><span class="line">char keyPtr[kCCKeySizeAES256+1];</span><br><span class="line">bzero(keyPtr, sizeof(keyPtr));</span><br><span class="line">[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];</span><br><span class="line">NSUInteger dataLength = [self length];</span><br><span class="line">size_t bufferSize = dataLength + kCCBlockSizeAES128;</span><br><span class="line">void *buffer = malloc(bufferSize);</span><br><span class="line">size_t numBytesEncrypted = 0;</span><br><span class="line">CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128,</span><br><span class="line">kCCOptionPKCS7Padding | kCCOptionECBMode,</span><br><span class="line">keyPtr, kCCBlockSizeAES128,</span><br><span class="line">NULL,</span><br><span class="line">[self bytes], dataLength,</span><br><span class="line">buffer, bufferSize,</span><br><span class="line">&amp;numBytesEncrypted);</span><br><span class="line">if (cryptStatus == kCCSuccess) &#123;</span><br><span class="line">return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];</span><br><span class="line">&#125;</span><br><span class="line">free(buffer);</span><br><span class="line">return nil;</span><br><span class="line">&#125;</span><br><span class="line">– (NSData *)AES256DecryptWithKey:(NSString *)key &#123;//解密</span><br><span class="line">char keyPtr[kCCKeySizeAES256+1];</span><br><span class="line">bzero(keyPtr, sizeof(keyPtr));</span><br><span class="line">[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];</span><br><span class="line">NSUInteger dataLength = [self length];</span><br><span class="line">size_t bufferSize = dataLength + kCCBlockSizeAES128;</span><br><span class="line">void *buffer = malloc(bufferSize);</span><br><span class="line">size_t numBytesDecrypted = 0;</span><br><span class="line">CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128,</span><br><span class="line">kCCOptionPKCS7Padding | kCCOptionECBMode,</span><br><span class="line">keyPtr, kCCBlockSizeAES128,</span><br><span class="line">NULL,</span><br><span class="line">[self bytes], dataLength,</span><br><span class="line">buffer, bufferSize,</span><br><span class="line">&amp;numBytesDecrypted);</span><br><span class="line">if (cryptStatus == kCCSuccess) &#123;</span><br><span class="line">return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];</span><br><span class="line">&#125;</span><br><span class="line">free(buffer);</span><br><span class="line">return nil;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>三、MD5数字摘要。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">#pragma mark – MD5 加密</span><br><span class="line">//String转化为md5加密String</span><br><span class="line">+ (NSString *)md5:(NSString *)str</span><br><span class="line">&#123;</span><br><span class="line">const char *cStr = [str UTF8String];</span><br><span class="line">unsigned char result[16];</span><br><span class="line">CC_MD5(cStr, strlen(cStr), result); // This is the md5 call</span><br><span class="line">return [NSString stringWithFormat:</span><br><span class="line">@”%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x”,</span><br><span class="line">result[0], result[1], result[2], result[3],</span><br><span class="line">result[4], result[5], result[6], result[7],</span><br><span class="line">result[8], result[9], result[10], result[11],</span><br><span class="line">result[12], result[13], result[14], result[15]</span><br><span class="line">];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>四、SHA512算法<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">//SHA512加密</span><br><span class="line">+ (NSString) getSHA512String:(NSString)s</span><br><span class="line">&#123;</span><br><span class="line">const char cstr = [s cStringUsingEncoding:NSUTF8StringEncoding];</span><br><span class="line">NSData *data = [NSData dataWithBytes:cstr length:s.length];</span><br><span class="line">uint8_t digest[CC_SHA512_DIGEST_LENGTH];</span><br><span class="line">CC_SHA512(data.bytes, data.length, digest);</span><br><span class="line">NSMutableString output = [NSMutableString stringWithCapacity:CC_SHA512_DIGEST_LENGTH * 2];</span><br><span class="line">for(int i = 0; i &lt; CC_SHA512_DIGEST_LENGTH; i++)</span><br><span class="line">[output appendFormat:@”%02x”, digest[i]];</span><br><span class="line">return output;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>五、Base64编码<br>首先下载GTMBase64文件，在工程中加入三个文件<br>GTMDefines.h<br>GTMBase64.h<br>GTMBase64.m<br>你可以在这里找到这三个文件<br><a href="http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/?r=87" target="_blank" rel="noopener">GTMBase64</a>,<br>你也可以在下面的demo里面找到这3个文件，demo会完整实现文章里面常用的3种编码方法。<br>我在此稍微封装一下：<br>.h文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">#pragma mark – base64</span><br><span class="line">+ (NSString)encodeBase64String:(NSString *)input;</span><br><span class="line">+ (NSString)decodeBase64String:(NSString )input;</span><br><span class="line">+ (NSString)encodeBase64Data:(NSData )data;</span><br><span class="line">+ (NSString)decodeBase64Data:(NSData )data;</span><br><span class="line">.m文件</span><br><span class="line">#pragma mark – base64</span><br><span class="line">+ (NSString)encodeBase64String:(NSString * )input &#123;</span><br><span class="line">NSData data = [input dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];</span><br><span class="line">data = [GTMBase64 encodeData:data];</span><br><span class="line">NSString *base64String = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];</span><br><span class="line">return base64String;</span><br><span class="line">&#125;</span><br><span class="line">+ (NSString)decodeBase64String:(NSString * )input &#123;</span><br><span class="line">NSData *data = [input dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];</span><br><span class="line">data = [GTMBase64 decodeData:data];</span><br><span class="line">NSString *base64String = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];</span><br><span class="line">return base64String;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>

  </section>

  

<section class="post-comments">
  <div id="disqus_thread"></div>
  <script type="text/javascript">
      var disqus_shortname = 'xtcel'; 
      /* * * DON'T EDIT BELOW THIS LINE * * */
      (function() {
          var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
          dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
          (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      })();
  </script>
  <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>


  
</article>


            <footer class="footer">

    <span class="footer__copyright">&copy; 2014-2015. | 由<a href="https://hexo.io/">Hexo</a>强力驱动 | 主题<a href="https://github.com/someus/huno">Huno</a></span>
    
</footer>
        </div>
    </div>

    <!-- js files -->
    <script src="/js/jquery.min.js"></script>
    <script src="/js/main.js"></script>
    <script src="/js/scale.fix.js"></script>
    

    

    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            MathJax.Hub.Config({
                tex2jax: {inlineMath: [['[latex]','[/latex]'], ['\\(','\\)']]}
            });
        });
    </script>



    

    <script src="/js/awesome-toc.min.js"></script>
    <script>
        $(document).ready(function(){
            $.awesome_toc({
                overlay: true,
                contentId: "post-content",
            });
        });
    </script>


    
    
    <!--kill ie6 -->
<!--[if IE 6]>
  <script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->

</body>
</html>
